package model

import (
	"fmt"
	"time"
)

type Employee struct {
	EmployeeId int
	Name       string
	Address    string

	Classification PaymentClassification
	Schedule       PaymentSchedule
	Method         PaymentMethod
	Affiliation
}

func NewEmployee(employee_id int, name, address string) *Employee {
	return &Employee{
		EmployeeId:  employee_id,
		Name:        name,
		Address:     address,
		Affiliation: &NoAffiliation{},
	}
}

func (e *Employee) IsPayDate(pay_date time.Time) bool {
	return e.Schedule.IsPayDate(pay_date)
}

func (e *Employee) GetPayPeriodStartDate(pay_period_end_date time.Time) time.Time {
	return e.Schedule.GetPayPeriodStartDate(pay_period_end_date)
}

func (e *Employee) Payday(pc *Paycheck) {
	pc.GrossPay = e.Classification.CalculatePay(pc)
	pc.Deductions = e.Affiliation.CalculateDeductions(pc)
	pc.NetPay = pc.GrossPay - pc.Deductions
	e.Method.Pay(pc)
	fmt.Printf("payed: %v to %s\n", pc.NetPay, e.Name)
}
